package ee.falcon.util;

import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;

public class ErrorMessager {
	
	//Error code declarations
	public static final String ERR001_FAIL_LOAD_LOOKANDFEEL = "ERROR #001: Failed to load look and feel - ";
	//Added constants
	public static final String ERR001R_FAIL_TO_START_PROFILES_FRAME = "ERROR #001R: Failed to load Profiles Main Frame- ";
	public static final String ERR002R_FAIL_TO_CONFIGURE_PARSER = "ERROR #002R: Failed to configure xml parser - ";
	public static final String ERR003R_FAIL_IN_JDOM2_LIBRARY = "ERROR #003R: XML parsing has failed due to JDOM2 library exception - ";
	public static final String ERR004R_IO_ERROR = "ERROR #004R: IOException occurred - ";
	public static final String ERR005R_FAIL_IN_XPATH_EXPRESSION= "ERROR #005R: Failed to excecute XPath expression - ";
	public static final String ERR006R_FAIL_TO_CONFIGURE_XML_TRANSFORMER_FACTORY= "ERROR #006R: Failed to configure xml Transformer factory - ";
	public static final String ERR007R_FAIL_TO_CONFIGURE_XML_SAX_PARSER= "ERROR #007R: Failed to configure xml SAX parser - ";
	
	/**
	 * A method for displaying error messages inside a JOptionPane. 
	 * 
	 * @param errorMsg	a string description of the occuring error
	 * @param e	the exception thrown
	 */
	public void errorMsg(final String errorMsg, final Exception e){
		SwingUtilities.invokeLater(new Runnable(){
			@Override
			public void run(){
				JOptionPane.showMessageDialog(null, errorMsg + "(" + e.getMessage() + ")!", "Error", JOptionPane.ERROR_MESSAGE);
			}
		});
	}
}